//使用懒汉
class SingletonLazy1{
    private static SingletonLazy1 instance = null;
    public static Object locker = new Object();

    public static SingletonLazy1 getInstance(){
        if (instance==null){
            synchronized (locker){
                if(instance==null){
                    instance = new SingletonLazy1();
                }
            }
        }
        return instance;
    }
    private SingletonLazy1(){

    }
}

public class Homework1 {
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            SingletonLazy1 s1 = SingletonLazy1.getInstance();
        });

        Thread t2 = new Thread(()->{
           SingletonLazy1 s2 = SingletonLazy1.getInstance();
        });

        t1.start();
        t2.start();
    }
}
